<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>canvas指纹追踪技术</title>
</head>
<body>
    <h4>canvas指纹追踪技术</h4>
    <img src="../img/img1.webp" alt="" srcset="" id="myimg">
    <script>
        let canvas = document.createElement('canvas');
        canvas.id = 'mycanvas';
        canvas.style.width = '300px';
        canvas.style.height = '250px';
        let ctx = canvas.getContext('2d');
        ctx.fillStyle =  'red';
        ctx.font = '26px 微软雅黑 ';
        ctx.fillText("你好就js", 10, 20);
        ctx.drawImage(document.querySelector('#myimg'), 0, 0);
        // 生成canvas指纹，即该canvas转化为base64格式的数据流，该数据流和用户系统浏览器等有关，数据不同，可以用于追踪用户
        let dataUrl = canvas.toDataURL();
        console.log('base64=>', dataUrl);
    </script>
</body>
</html>